#ifndef _AK_CONFIG_H_
#define _AK_CONFIG_H_

#define DAY_PER_WEEK	7
#define MAX_RECORD_PLAN_NUM 3

struct video_config {
    int min_qp;
    int max_qp;
    int v720p_fps;
    int v720p_min_kbps;
    int v720p_max_kbps;

    int vga_fps;
    int vga_min_kbps;
    int vga_max_kbps;

    int gop_len;
	int	quality;
	int	pic_ch;
	int video_mode;
	int method;
};

struct sys_user_config {
    char name[20];					//user name
    char secret[20];				//password
    char dev_name[100];				//device name
    char uid_name[100];				//uid file name
	unsigned int soft_version;
};

struct pictrue_config {
    int chanel;
};

struct sys_net_config {
	int dhcp;			//0:Fixed IP  1:dynamic ip
	char ipaddr[16];	//local ip
	char netmask[16];	//net mask
	char gateway[16];
	char firstdns[16];	//main dns
	char backdns[16];	//second dns
};

struct record_plan_config {
    int active;			//active flag of plan record
    /* week day enable flag, 0 Sunday, 1-6 Monday to Saturday */
    int week_enalbe[DAY_PER_WEEK];
    time_t start_time;	//senconds from current day's 00:00:00
    time_t end_time;	//senconds from current day's 00:00:00
};

struct video_record_config {
	int server_flag;	//start record server
	int record_mode;	//1->plan record,  2->alarm record
	int duration;		//duration of each record file(unit: second)
	
	int sample_rate;	//audio sample rate
    int save_cyc_flag;	//cycle record flag, 1->cycle, 0->normal
    int save_file_fps;	//originale fps
    int save_file_kbps;
    int min_file_fps;	//min fps when switch record frame    
    char path[255];		//plan-record file saving path

    int alarm_pre_time; //keeping video and audio before alarm record trigger
    int alarm_stop_time;//stop record after keep silence time

    struct record_plan_config plan[MAX_RECORD_PLAN_NUM];
};

struct camera_disp_config {
    int main_width;
    int main_height;
    int sub_width;
    int sub_height;

	int osd_rate;		//display rate info OSD
	int osd_position;
    int osd_switch;
    char osd_name[50];
    int time_switch;
    int date_format;
    int hour_format;
    int week_format;
	int day_ctrl;
};

struct sys_alarm_config {
    int md_set;
    int md_level_1;
    int md_level_2;
    int md_level_3;

    int sd_set;
    int sd_level_1;
    int sd_level_2;
    int sd_level_3;

    int i2o_detection;
    int smoke_detection;
    int shadow_detection;
    int other_detection;

    int send_type;
	int interval_time;
	int send_msg_time;
};

struct sys_onvif_config {
    int main_fps;
    int main_kbps;
    int main_quality;
    int sub_fps;
    int sub_kbps;
    int sub_quality;
};

struct sys_cloud_config {
    int onvif;
    int dana;
    int rtsp;
    int tencent;
};

enum wifi_enc_type {
	WIFI_ENCTYPE_INVALID,
	WIFI_ENCTYPE_NONE,
	WIFI_ENCTYPE_WEP,
	WIFI_ENCTYPE_WPA_TKIP,
	WIFI_ENCTYPE_WPA_AES,
	WIFI_ENCTYPE_WPA2_TKIP,
	WIFI_ENCTYPE_WPA2_AES
};

struct sys_wifi_config {
	char ssid[32];
	char mode[32];
	char passwd[32];
	enum wifi_enc_type enc_type;
	char ap_ssid[32];
	char ap_pswd[32];
};

struct cloud_alarm_config {
	unsigned char IsOpenMotionDetection;//close:1 open:0
	unsigned char MontionDetectionLevel;//level: 0  1  2    2 is Highest

	unsigned char IsOpenSoundDetection;
	unsigned char SoundDetectionLevel;

	unsigned char IsOpenI2ODetection;
	unsigned char I2ODetectionLevel;

	unsigned char IsOpenShadowDetection;
	unsigned char ShadowDetectionLevel;

	unsigned char IsOpenSmokeDetection;
	unsigned char SmokeetectionLevel;

	unsigned char IsOpenOther;
	unsigned char OtherDetectionLevel;
};

/**
 * ak_config_get_version - get config version
 * return: version string
 */
const char* ak_config_get_version(void);

/**
 * ak_config_get_record: get record config
 * return: record config struct pointer
 */
struct video_record_config* ak_config_get_record(void);

/**
 * ak_config_set_record_plan: set record config
 * @record[IN]: record config
 * return: void
 */
void ak_config_set_record_plan(struct video_record_config *record);

/**
 * ak_config_get_sys_alarm: get system alarm config
 * return: system alarm config struct pointer
 */
struct sys_alarm_config* ak_config_get_sys_alarm(void);

/**
 * ak_config_set_sys_alarm: set system alarm config
 * return: void
 */
void ak_config_set_sys_alarm(void);

/**
 * ak_config_set_record_plan_by_net: set record plan config 
 * @plan[IN]: record plan config
 * return: void
 */
void ak_config_set_record_plan_by_net(struct record_plan_config *plan);

/**
 * ak_config_init_ini: init ini module
 * return: void
 */
void ak_config_init_ini(void);

/**
 * ak_config_release_ini: destroy ini module
 * return: void
 */
void ak_config_release_ini(void);

/**
 * ak_config_flush_data: flush data
 * return: void
 */
void ak_config_flush_data(void);

/**
 * ak_config_update_ssid:  get wifi ssid  from config file
 * return: 0 -> success; -1 -> fail; 
 * notes: wifi ssid configure change by script cmd, we need to 
 *          update configure copy in memory.
 *          it is special.
 */
int ak_config_update_ssid(void);

/**
 * ak_config_get_ptz: get ptz control config
 * @con[OUT]: ptz control config
 * @para1[IN]: ptz control index
 * return: void
 */
void ak_config_get_ptz(void *con, int para1);

/**
 * ak_config_set_ptz: set ptz control config
 * @con[IN]: ptz control config
 * @para1[IN]: ptz control index
 * return: void
 */
void ak_config_set_ptz(void *con, int para1);

/**
 * ak_config_set_ptz_unhit: set first ptz control config
 * @con[IN]: ptz control config
 * return: void
 */
void ak_config_set_ptz_unhit(void *con);

/**
 * ak_config_get_ptz_unhit: get first ptz control config
 * @con[OUT]: ptz control config
 * return: void
 */
void ak_config_get_ptz_unhit(void *con);

/** ak_config_get_sys_video: get system video config, title: video
 * @void
 * return: video config info pointer
 */
struct video_config* ak_config_get_sys_video(void);

/**
 * ak_config_set_sys_video: set video config
 * @video[IN]: video config
 * return: void
 */
void ak_config_set_sys_video(struct video_config *video);

/**
 * ak_config_get_sys_cloud: get system cloud config
 * return: cloud config struct pointer
 */
struct sys_cloud_config* ak_config_get_sys_cloud(void);

/**
 * ak_config_get_sys_onvif: get onvif config
 * return: onvif config struct pointer
 */
struct sys_onvif_config* ak_config_get_sys_onvif(void);

/**
 * ak_config_set_sys_onvif: set onvif config
 * @onvif[IN]: onvif config
 * return: void
 */
void ak_config_set_sys_onvif(struct sys_onvif_config *onvif);

/**
 * ak_config_get_sys_net: get system network config
 * return: network config struct pointer
 */
struct sys_net_config* ak_config_get_sys_net(void);

/**
 * ak_config_set_sys_net: set system network config
 * @net[IN]: network config
 * return: void
 */
void ak_config_set_sys_net(struct sys_net_config *net);

/**
 * ak_config_get_sys_wifi: get system wifi config
 * return: wifi config struct pointer
 */
struct sys_wifi_config* ak_config_get_sys_wifi(void);

/**
 * ak_config_set_sys_wifi: set system wifi config
 * @wifi[IN]: wifi config
 * @save_ssid_f[IN]: save ssid or not
 * return: void
 */
void ak_config_set_sys_wifi(struct sys_wifi_config *wifi,int save_ssid_f);

/**
 * ak_config_set_camera_info: set camera config
 * @camera[IN]: camera config
 * return: void
 */
void ak_config_set_camera_info(struct camera_disp_config *camera);

/**
 * ak_config_get_camera_info: get camera config
 * return: camera config struct pointer
 */
struct camera_disp_config* ak_config_get_camera_info(void);

/**
 * ak_config_set_system_user: set user info config
 * @user_info[IN]: user info config
 * return: void
 */
void ak_config_set_system_user(struct sys_user_config *user_info);

/**
 * ak_config_get_system_user: get system user info config
 * return: user info config struct pointer
 */
struct sys_user_config* ak_config_get_system_user(void);

void *ak_config_set_record_time(int time_ms);
void *ak_config_set_sys_wifi_ap(char *name);

#endif
